/**
 * 深度(m),岩性,K(%),Si(%),Al(%),Ca(%),Mg(%),S(%),P(%),Fe(%),Mn(%)
 */
import * as echarts from "echarts"
import { dataset } from "./dataset/element-cross.js"

export const mockdata = [
  [1000, "云质砂岩", 3.2, 54.1, 32.5, 12.3, 8.3, 0.26, 0.3, 0.6514, 0.12],
  [1010, "粉细砂岩", 1.8, 68.2, 18.7, 3.1, 2.5, 0.055, 0.04, 0.3157, 0.08],
  [1020, "泥晶白云岩", 1.1, 38.5, 8.2, 18.2, 18.2, 0.625, 0.16, 0.2186, 0.25],
  [1030, "长石岩屑砂岩", 3.8, 62.3, 25.4, 5.8, 4.1, 0.115, 0.1, 0.5529, 0.15],
  [1040, "砂质云岩", 1.5, 45.6, 12.3, 15.6, 13.5, 0.445, 0.14, 0.2929, 0.18],
  [1050, "泥岩", 4.5, 42.1, 40.2, 2.2, 4.8, 0.165, 0.42, 0.7914, 0.32],
  [1060, "粉细砂岩", 2.1, 71.5, 15.6, 2.5, 1.2, 0.04, 0.02, 0.27, 0.05],
  [1070, "云质砂岩", 2.8, 58.9, 28.9, 9.8, 7.6, 0.335, 0.24, 0.5729, 0.2],
  [1080, "泥晶白云岩", 0.9, 36.7, 7.1, 19.5, 17.5, 0.71, 0.18, 0.1829, 0.28],
  [1090, "长石岩屑砂岩", 4.2, 59.8, 27.1, 4.3, 3.9, 0.09, 0.08, 0.5029, 0.11],
  [1100, "砂质云岩", 0.8, 47.2, 10.8, 16.9, 12.1, 0.505, 0.12, 0.26, 0.22],
  [1110, "泥晶白云岩", 0.9, 39.2, 9.5, 17.8, 17.5, 0.675, 0.2, 0.2071, 0.3],
  [1120, "泥岩", 5, 44.5, 38.7, 1.8, 5.5, 0.2, 0.5, 0.8586, 0.35],
  [1130, "粉细砂岩", 1.2, 65.8, 20.1, 4.5, 0.8, 0.11, 0.06, 0.3643, 0.1],
  [1140, "云质砂岩", 4.1, 56.3, 30.1, 11.2, 9.1, 0.39, 0.36, 0.6886, 0.17],
  [1150, "长石岩屑砂岩", 3.5, 63.5, 23.2, 6.5, 5.2, 0.15, 0.12, 0.6043, 0.14],
  [1160, "砂质云岩", 2.3, 43.1, 14.2, 14.1, 14.8, 0.475, 0.22, 0.3343, 0.19],
  [1170, "泥晶白云岩", 1.5, 35.9, 6.5, 20, 19, 0.75, 0.24, 0.2286, 0.4],
  [1180, "泥岩", 4.8, 41.2, 39.5, 2.5, 2.1, 0.19, 0.38, 0.7471, 0.29],
  [1190, "粉细砂岩", 2.5, 67, 17.2, 3.8, 3.7, 0.075, 0.04, 0.2971, 0.07],
  [1200, "云质砂岩", 3.9, 57.5, 29.5, 10.5, 6.9, 0.305, 0.3, 0.6243, 0.16],
  [1210, "长石岩屑砂岩", 4, 61, 26, 5, 4.5, 0.125, 0.1, 0.5286, 0.13],
  [1220, "砂质云岩", 1.9, 46, 11.5, 15, 11.2, 0.425, 0.16, 0.2786, 0.21],
  [1230, "泥晶白云岩", 0.7, 37, 7.8, 18.5, 16.8, 0.64, 0.14, 0.1929, 0.26],
  [1240, "泥岩", 5.2, 43.8, 41, 2, 4.3, 0.21, 0.46, 0.8257, 0.38],
  [1250, "粉细砂岩", 0.9, 70.1, 14.3, 2, 1.5, 0.045, 0, 0.2457, 0.04],
  [1260, "云质砂岩", 2.2, 55, 31.8, 8.9, 8.7, 0.275, 0.2, 0.67, 0.19],
  [1270, "长石岩屑砂岩", 3.7, 60.5, 24.7, 5.5, 3.2, 0.1, 0.06, 0.5143, 0.1],
  [1280, "砂质云岩", 2, 44.2, 13, 14.5, 13.9, 0.45, 0.2, 0.3114, 0.2],
  [1290, "泥晶白云岩", 1.3, 36.5, 8, 19, 18.5, 0.695, 0.22, 0.2257, 0.33],
  [1300, "泥岩", 4.9, 45, 37.5, 1.5, 5, 0.175, 0.4, 0.7571, 0.31],
  [1310, "粉细砂岩", 1.7, 66.5, 19.5, 4, 2.8, 0.09, 0.08, 0.3429, 0.09],
  [1320, "云质砂岩", 4.5, 53.2, 33.2, 13.1, 7.3, 0.36, 0.4, 0.7214, 0.23],
  [1330, "长石岩屑砂岩", 4.3, 58.7, 28.3, 4.8, 4.8, 0.14, 0.14, 0.5686, 0.16],
  [1340, "砂质云岩", 0.5, 48.5, 9.2, 17.5, 12.5, 0.56, 0.1, 0.2429, 0.24],
  [1350, "泥晶白云岩", 1, 40.1, 10.1, 16.5, 17.2, 0.6, 0.16, 0.1857, 0.27],
  [1360, "泥岩", 5.4, 40.5, 42.5, 3, 3.5, 0.225, 0.56, 0.8357, 0.42],
  [1370, "粉细砂岩", 2.4, 69, 16, 3.5, 0.5, 0.065, 0.02, 0.2786, 0.06],
  [1380, "云质砂岩", 3, 52, 34.5, 7.5, 9.5, 0.225, 0.18, 0.6786, 0.21],
  [1390, "长石岩屑砂岩", 3.9, 64, 22, 7, 5.5, 0.175, 0.16, 0.5857, 0.18],
  [1400, "砂质云岩", 2.1, 42, 15, 13, 14.2, 0.4, 0.24, 0.3214, 0.17],
  [1410, "泥晶白云岩", 1.6, 35, 5.5, 21, 19.2, 0.725, 0.26, 0.25, 0.45],
  [1420, "泥岩", 4.7, 46.2, 36.8, 2.8, 4, 0.15, 0.36, 0.7286, 0.28],
  [1430, "粉细砂岩", 1.1, 64.8, 21.8, 5.2, 2, 0.125, 0.1, 0.3829, 0.11],
  [1440, "云质砂岩", 2.9, 59.5, 27.8, 10, 8, 0.325, 0.26, 0.6286, 0.15],
  [1450, "长石岩屑砂岩", 4.1, 57.2, 29.2, 4, 3.7, 0.095, 0.08, 0.4857, 0.09],
  [1460, "砂质云岩", 1.8, 49, 10.5, 16, 11.8, 0.49, 0.18, 0.2686, 0.23],
  [1470, "泥晶白云岩", 0.6, 38.2, 8.5, 17, 16.5, 0.575, 0.12, 0.1714, 0.22],
  [1480, "泥岩", 5.3, 41.8, 43.2, 1.2, 5.3, 0.24, 0.52, 0.85, 0.39],
  [1490, "粉细砂岩", 2.7, 68.5, 15.2, 3, 1.8, 0.05, 0.04, 0.3071, 0.08],
  [1500, "云质砂岩", 3.8, 54, 32, 9.5, 7, 0.29, 0.32, 0.6, 0.14],
  [1510, "长石岩屑砂岩", 3.6, 62.8, 23.8, 6.2, 4.3, 0.11, 0.1, 0.5429, 0.12],
  [1520, "砂质云岩", 2.4, 45.5, 13.5, 14.8, 13.2, 0.41, 0.2, 0.2857, 0.16],
  [1530, "泥晶白云岩", 1.2, 37.5, 7.2, 18.8, 18, 0.65, 0.18, 0.2, 0.29],
  [1540, "泥岩", 4.6, 47.5, 35.5, 3.5, 3, 0.14, 0.3, 0.7071, 0.26],
  [1550, "粉细砂岩", 0.8, 63, 22.5, 6, 2.3, 0.15, 0.12, 0.4071, 0.13],
  [1560, "云质砂岩", 4, 51.5, 35.5, 12.5, 9, 0.375, 0.38, 0.7, 0.25],
  [1570, "长石岩屑砂岩", 4.4, 59, 27.5, 5.3, 5, 0.16, 0.18, 0.5786, 0.2],
  [1580, "砂质云岩", 0.9, 50, 8.8, 18, 12.8, 0.525, 0.08, 0.2357, 0.26],
  [1590, "泥晶白云岩", 1.4, 39.5, 9.8, 16.2, 17.8, 0.61, 0.2, 0.1971, 0.31],
  [1600, "泥岩", 5.6, 39.2, 44.5, 0.8, 4.6, 0.26, 0.6, 0.8786, 0.46],
  [1610, "粉细砂岩", 1.5, 67.5, 18, 4.2, 0.7, 0.085, 0.06, 0.3357, 0.1],
  [1620, "云质砂岩", 2.6, 56.5, 26.5, 8, 8.5, 0.24, 0.16, 0.5929, 0.18],
  [1630, "长石岩屑砂岩", 3.4, 61.5, 24.2, 5.2, 3.5, 0.085, 0.04, 0.5029, 0.08],
  [1640, "砂质云岩", 2.5, 41.5, 14.8, 13.5, 14.5, 0.39, 0.26, 0.3286, 0.15],
  [1650, "泥晶白云岩", 1.8, 34.5, 6, 22, 19.5, 0.775, 0.28, 0.2643, 0.48],
  [1660, "泥岩", 4.4, 48.8, 34.2, 4, 2.5, 0.11, 0.24, 0.6714, 0.24],
  [1670, "粉细砂岩", 2, 65.2, 20.5, 4.8, 3, 0.1, 0.08, 0.3571, 0.09],
  [1680, "云质砂岩", 3.3, 58, 28.2, 9.2, 7.8, 0.315, 0.28, 0.6457, 0.17],
  [1690, "长石岩屑砂岩", 4.6, 60, 26.8, 4.5, 4, 0.13, 0.12, 0.5357, 0.11],
  [1700, "砂质云岩", 1.7, 47.8, 11.2, 15.5, 11.5, 0.46, 0.14, 0.2714, 0.19],
  [1710, "泥晶白云岩", 0.8, 40.5, 10.5, 15, 16.2, 0.55, 0.1, 0.1643, 0.2],
  [1720, "泥岩", 5.1, 42.5, 41.5, 1, 5.7, 0.185, 0.44, 0.8, 0.34],
  [1730, "粉细砂岩", 2.3, 66, 19, 4.5, 1, 0.075, 0.04, 0.3143, 0.07],
  [1740, "云质砂岩", 2.7, 53.5, 33.5, 11.8, 9.8, 0.345, 0.34, 0.6929, 0.22],
  [1750, "长石岩屑砂岩", 3.3, 63, 22.5, 7.2, 5.8, 0.19, 0.14, 0.6214, 0.19],
  [1760, "砂质云岩", 2.2, 43.8, 12.8, 14.2, 13.7, 0.435, 0.22, 0.3, 0.18],
  [1770, "泥晶白云岩", 1.7, 36.2, 7.5, 19.5, 18.7, 0.7, 0.24, 0.2357, 0.37],
  [1780, "泥岩", 4.3, 49.5, 33, 5.5, 3.8, 0.125, 0.2, 0.6429, 0.22],
  [1790, "粉细砂岩", 1.4, 62, 23, 6.5, 2.2, 0.16, 0.14, 0.3929, 0.14],
  [1800, "云质砂岩", 4.2, 50.5, 36, 13.5, 8.2, 0.35, 0.42, 0.7357, 0.27],
  [1810, "长石岩屑砂岩", 4.7, 58, 29, 5.5, 4.7, 0.17, 0.2, 0.5571, 0.17],
  [1820, "砂质云岩", 1, 51.2, 9.5, 17.2, 12.3, 0.54, 0.06, 0.2214, 0.25],
  [1830, "泥晶白云岩", 1.1, 41, 11, 15.8, 17, 0.59, 0.16, 0.1786, 0.3],
  [1840, "泥岩", 5.5, 38, 45, 0.5, 4.4, 0.275, 0.64, 0.8929, 0.5],
  [1850, "粉细砂岩", 0.6, 69.5, 13.5, 1.5, 0.3, 0.025, 0, 0.2286, 0.02],
  [1860, "云质砂岩", 3.1, 57, 25.8, 7.8, 7.2, 0.25, 0.14, 0.5643, 0.16],
  [1870, "长石岩屑砂岩", 3.8, 64.5, 21.2, 6.8, 3, 0.105, 0.06, 0.5257, 0.09],
  [1880, "砂质云岩", 2.6, 42.5, 15.5, 13.2, 14, 0.375, 0.28, 0.3143, 0.14],
  [1890, "泥晶白云岩", 1.9, 35.5, 6.2, 20.5, 19.8, 0.76, 0.3, 0.2714, 0.43],
  [1900, "泥岩", 4.2, 50, 32.5, 6, 5.2, 0.1, 0.16, 0.6, 0.2],
  [1910, "粉细砂岩", 2.8, 64, 17.5, 5, 1.7, 0.14, 0.1, 0.3714, 0.12],
  [1920, "云质砂岩", 3.5, 55.5, 31, 10.2, 8.8, 0.3, 0.36, 0.6571, 0.2],
  [1930, "长石岩屑砂岩", 4.5, 57.5, 28.5, 4.2, 4.9, 0.12, 0.12, 0.4929, 0.1],
  [1940, "砂质云岩", 1.3, 52.5, 8, 18.5, 11, 0.575, 0.04, 0.2, 0.28],
  [1950, "泥晶白云岩", 0.5, 42, 12, 14, 16, 0.525, 0.08, 0.1429, 0.18],
  [1960, "泥岩", 5.7, 37.5, 46, 1.2, 3.3, 0.29, 0.7, 0.9143, 0.47],
  [1970, "粉细砂岩", 0.7, 68, 16.5, 3.8, 2.6, 0.175, 0.16, 0.4143, 0.15],
  [1980, "云质砂岩", 4.8, 49, 37, 14, 9.3, 0.4, 0.44, 0.7429, 0.29],
  [1990, "长石岩屑砂岩", 3.2, 65, 20.5, 8, 5.3, 0.2, 0.22, 0.6286, 0.21]
]

/**
 * 随机将数组分成指定数量的段
 * @param {Array} arr - 要分割的数组
 * @param {number} n - 要分割的段数
 * @returns {Array<Array>} 分割后的数组段
 */
export function splitArrayRandomly(arr, n) {
  if (!Array.isArray(arr)) {
    throw new TypeError("输入必须是数组")
  }

  if (typeof n !== "number" || n <= 0 || !Number.isInteger(n)) {
    throw new TypeError("段数必须是正整数")
  }

  if (n > arr.length) {
    throw new Error("段数不能大于数组长度")
  }

  // 创建索引点数组
  const indices = Array.from({ length: arr.length }, (_, i) => i)

  // 随机选择分割点
  const splitPoints = []
  while (splitPoints.length < n - 1) {
    const randomIndex = Math.floor(Math.random() * indices.length)
    splitPoints.push(indices[randomIndex])
    indices.splice(randomIndex, 1)
  }

  // 排序分割点
  splitPoints.sort((a, b) => a - b)

  // 创建分段
  const result = []
  let start = 0

  for (const point of splitPoints) {
    result.push(arr.slice(start, point + 1))
    start = point + 1
  }

  // 添加最后一段
  result.push(arr.slice(start))

  // 补充最后一个值
  result.push([arr[arr.length - 1]])
  return result
}

export const none = 0
export const you = 1
export const youshui = 2 // 油水同层
export const shui = 3
export const qi = 4
export const qishui = 5
export const bad_you = 6
export const gan = 7
export const shui_you = 8 // 含油水层
export const colors = [
  "transparent",
  "#00ae38",
  "#eeacff",
  "#0002f8",
  "#f90401",
  "#d72dba",
  "#e3fbe1",
  "#e2d44c",
  "#66b1ff"
]

const lithology_lineStyle = { color: "#c00000", width: 3 }
export const lithology_lines = [
  {
    type: "line",
    symbol: "none",
    lineStyle: lithology_lineStyle,
    data: [
      [6, 0],
      [6, 6]
    ]
  },
  {
    type: "line",
    symbol: "none",
    lineStyle: lithology_lineStyle,
    data: [
      [11, 0],
      [11, 6]
    ]
  },
  {
    type: "line",
    symbol: "none",
    lineStyle: lithology_lineStyle,
    data: [
      [16, 0],
      [16, 6]
    ]
  },
  {
    type: "line",
    symbol: "none",
    lineStyle: lithology_lineStyle,
    data: [
      [0, 3],
      [6, 3]
    ]
  },
  {
    type: "line",
    symbol: "none",
    lineStyle: { color: "red", width: 3 },
    data: [
      [0, 4.5],
      [6, 4.5]
    ]
  }
]

const bc = "black" // 边框颜色
const bgcolor = "#faff7f"
const stdtypes = [
  { name: "hzfsy", label: "长石岩屑砂岩", color: bgcolor, height: 9 },
  { name: "xsy", label: "粉细砂岩", color: bgcolor, height: 9 },
  { name: "nzfsy", label: "云质砂岩", color: bgcolor, height: 9 },
  { name: "fszny", label: "砂质云岩", color: bgcolor, height: 6 },
  { name: "ny", label: "泥晶白云岩", color: "#a5d6a7", height: 6 },
  { name: "nzxsy", label: "泥岩", color: bgcolor, height: 7 }
]

const elementGrouped = [[], [], [], [], [], []]

for (const it of mockdata) {
  const [mg, k] = [it[6], it[2]]

  if (mg < 6) {
    if (k < 3) elementGrouped[1].push([mg, k])
    else if (k < 4.5) elementGrouped[0].push([mg, k])
    else elementGrouped[5].push([mg, k])
  } else if (mg < 11 && k > 1 && k < 5) {
    elementGrouped[2].push([mg, k])
  } else if (mg < 16 && k > 0 && k < 3) {
    elementGrouped[3].push([mg, k])
  } else if (k > 0 && k < 2) {
    elementGrouped[4].push([mg, k])
  } else {
    elementGrouped[5].push([mg, k])
  }
}
export { elementGrouped }

export function groupedElement(index1, index2) {
  const result = [[], [], [], [], [], []]

  for (const it of dataset) {
    const [mg, k] = [it[index1], it[index2]]

    if (mg < 6) {
      if (k < 3) result[1].push([mg, k])
      else if (k < 4.5) result[0].push([mg, k])
      else result[5].push([mg, k])
    } else if (mg < 11 && k > 1 && k < 5) {
      result[2].push([mg, k])
    } else if (mg < 16 && k > 0 && k < 3) {
      result[3].push([mg, k])
    } else if (k > 0 && k < 2) {
      result[4].push([mg, k])
    } else {
      result[5].push([mg, k])
    }
  }
  return result
}

const mockdataset1 = dataset
  .map((t, i) => {
    const [mg, k, ch] = [t[1], t[7], t[0]]
    let type = stdtypes[5]
    if (mg < 6) {
      if (k < 3) type = stdtypes[1]
      else if (k < 4.5) type = stdtypes[0]
      else type = stdtypes[5]
    } else if (mg < 11) {
      if (k > 1 && k < 5) type = stdtypes[2]
    } else if (mg < 16) {
      if (k > 0 && k < 3) type = stdtypes[3]
    } else {
      if (k > 0 && k < 2) type = stdtypes[4]
    }

    const nh = i + 1 < dataset.length ? dataset[i + 1][0] : ch
    return {
      name: type.label,
      value: [i, ch, nh, nh - ch, type.height, type.name],
      itemStyle: {
        normal: {
          color: type.color
        }
      }
    }
  })
  .reduce((acc, cur) => {
    if (acc.length && acc[acc.length - 1].value[5] == cur.value[5]) {
      acc[acc.length - 1].value[2] += cur.value[3]
      acc[acc.length - 1].value[3] += cur.value[3]
    } else {
      acc.push(cur)
    }
    return acc
  }, [])

const mockdataset2 = dataset.map((t, i) => {
  const index = Math.floor(Math.random() * stdtypes.length)
  const type = stdtypes[index]
  const ch = dataset[i][0]
  const nh = i + 1 < dataset.length ? dataset[i + 1][0] : ch
  return {
    name: type.label,
    value: [i, ch, nh, 0, type.height, type.label],
    itemStyle: {
      normal: {
        color: "#faff7f"
      }
    }
  }
})

// [1000, "云质砂岩", 3.2, 54.1, 32.5, 12.3, 8.3, 0.26, 0.3, 0.6514, 0.12],
function renderExplain(params, api) {
  var categoryIndex = api.value(0)
  var start = api.coord([categoryIndex, api.value(1)])
  var end = api.coord([categoryIndex, api.value(2)])
  var [_h, _w] = [api.value(3), 10]
  var [width, height] = api.size([1, _h])
  const wid = width * (_w / 10)
  const [x1, y1, x2, y2] = [0, start[1], width * 10, end[1]]
  var rectShape = echarts.graphic.clipRectByRect(
    {
      x: 0,
      y: start[1],
      width: width * 10,
      height: height
    },
    {
      x: params.coordSys.x,
      y: params.coordSys.y,
      width: params.coordSys.width,
      height: params.coordSys.height
    }
  )
  const ret = {
    type: "group",
    children: [
      {
        type: "rect",
        transition: ["shape"],
        shape: rectShape,
        style: { lineWidth: 1, stroke: "black", fill: "green" }
      }
    ]
  }
  const geotype = Math.floor(Math.random() * 9)
  if ([you, shui, qi, gan].includes(geotype)) return null

  if (Math.random() > 0.05) return null

  if (geotype == youshui) {
    ret.children = [
      {
        type: "polygon",
        shape: {
          points: [
            [x1, y1],
            [x2, y1],
            [x1, y2]
          ]
        },
        style: { stroke: "black", lineWidth: 1, fill: colors[you] }
      },
      {
        type: "polygon",
        shape: {
          points: [
            [x2, y1],
            [x1, y2],
            [x2, y2]
          ]
        },
        style: { stroke: "black", lineWidth: 1, fill: colors[shui] }
      }
    ]
    return ret
  }
  if (geotype == bad_you) {
    const lines = Array.from({ length: 9 }, (_, i) => {
      return {
        type: "line",
        shape: {
          x1,
          y1: (y1 * (10 - i)) / 10 + (y2 * i) / 10,
          x2,
          y2: (y1 * (9 - i)) / 10 + (y2 * (i + 1)) / 10
        },
        style: { stroke: "black", lineWidth: 1 }
      }
    })
    ret.children = [
      {
        type: "rect",
        transition: ["shape"],
        shape: rectShape,
        style: { lineWidth: 1, stroke: "black", fill: colors[bad_you] }
      },
      ...lines
    ]
    return ret
  }

  return [none, shui_you].includes(geotype) ? null : ret
}
function renderYanxing(params, api) {
  var categoryIndex = api.value(0)
  var start = api.coord([categoryIndex, api.value(1)])
  var end = api.coord([categoryIndex, api.value(2)])
  var [_h, _w, yxName] = [api.value(3), api.value(4), api.value(5)]
  var [width, height] = api.size([1, _h])
  var wid = width * (_w / 10)
  var [x1, y1, x2, y2] = [start[0] - width / 2, start[1], end[0] - width / 2 + wid, end[1]]
  var rectShape = echarts.graphic.clipRectByRect(
    {
      x: start[0] - width / 2,
      y: start[1],
      width: width * (_w / 10),
      height: height
    },
    {
      x: params.coordSys.x,
      y: params.coordSys.y,
      width: params.coordSys.width,
      height: params.coordSys.height
    }
  )
  const ret = {
    type: "group",
    children: [
      {
        type: "rect",
        transition: ["shape"],
        shape: rectShape,
        style: { ...api.style(), lineWidth: 1, stroke: bc }
      }
    ]
  }
  if (yxName == "hzfsy") {
    ret.children.push({
      type: "line",
      shape: {
        x1: x1 + (wid * 2) / 10,
        y1: (y1 * 2) / 3 + y2 / 3,
        x2: x1 + (wid * 2) / 10,
        y2: (y1 * 1) / 3 + (y2 * 2) / 3
      },
      style: { stroke: "black", lineWidth: 1 }
    })
    ret.children.push({
      type: "circle",
      shape: {
        cx: x1 + (wid * 4.5) / 10,
        cy: (y1 + y2) / 2,
        r: 1
      },
      style: { stroke: "black", fill: "black", lineWidth: 1 }
    })
    ret.children.push({
      type: "circle",
      shape: {
        cx: x1 + (wid * 5.5) / 10,
        cy: (y1 + y2) / 2,
        r: 1
      },
      style: { stroke: "black", fill: "black", lineWidth: 1 }
    })
    ret.children.push({
      type: "circle",
      shape: {
        cx: x1 + (wid * 7.5) / 10,
        cy: (y1 + y2) / 2,
        r: 1
      },
      style: { stroke: "black", fill: "black", lineWidth: 1 }
    })
    ret.children.push({
      type: "circle",
      shape: {
        cx: x1 + (wid * 8.5) / 10,
        cy: (y1 + y2) / 2,
        r: 1
      },
      style: { stroke: "black", fill: "black", lineWidth: 1 }
    })
  } else if (yxName == "xsy") {
    ret.children.push({
      type: "circle",
      shape: {
        cx: x1 + (wid * 2) / 10,
        cy: (y1 + y2) / 2,
        r: 1
      },
      style: { stroke: "black", fill: "black", lineWidth: 1 }
    })
    ret.children.push({
      type: "circle",
      shape: {
        cx: x1 + (wid * 4) / 10,
        cy: (y1 + y2) / 2,
        r: 1
      },
      style: { stroke: "black", fill: "black", lineWidth: 1 }
    })
    ret.children.push({
      type: "circle",
      shape: {
        cx: x1 + (wid * 6) / 10,
        cy: (y1 + y2) / 2,
        r: 1
      },
      style: { stroke: "black", fill: "black", lineWidth: 1 }
    })
    ret.children.push({
      type: "circle",
      shape: {
        cx: x1 + (wid * 8) / 10,
        cy: (y1 + y2) / 2,
        r: 1
      },
      style: { stroke: "black", fill: "black", lineWidth: 1 }
    })
  } else if (yxName == "nzfsy") {
    ret.children.push({
      type: "line",
      shape: {
        x1: x1 + wid / 10,
        y1: y1 / 2 + y2 / 2,
        x2: x1 + (wid * 3) / 10,
        y2: y1 / 2 + y2 / 2
      },
      style: { stroke: "black", lineWidth: 1 }
    })
    ret.children.push({
      type: "circle",
      shape: {
        cx: x1 + (wid * 4.5) / 10,
        cy: (y1 + y2) / 2,
        r: 1
      },
      style: { stroke: "black", fill: "black", lineWidth: 1 }
    })
    ret.children.push({
      type: "circle",
      shape: {
        cx: x1 + (wid * 5.5) / 10,
        cy: (y1 + y2) / 2,
        r: 1
      },
      style: { stroke: "black", fill: "black", lineWidth: 1 }
    })
    ret.children.push({
      type: "circle",
      shape: {
        cx: x1 + (wid * 7.5) / 10,
        cy: (y1 + y2) / 2,
        r: 1
      },
      style: { stroke: "black", fill: "black", lineWidth: 1 }
    })
    ret.children.push({
      type: "circle",
      shape: {
        cx: x1 + (wid * 8.5) / 10,
        cy: (y1 + y2) / 2,
        r: 1
      },
      style: { stroke: "black", fill: "black", lineWidth: 1 }
    })
  } else if (yxName == "ny") {
    ret.children.push({
      type: "line",
      shape: {
        x1: x1 + wid / 10,
        y1: (y1 + y2) / 2,
        x2: x1 + (wid * 3) / 10,
        y2: (y1 + y2) / 2
      },
      style: { stroke: "black" }
    })
    ret.children.push({
      type: "line",
      shape: {
        x1: x1 + wid * 0.4,
        y1: (y1 + y2) / 2,
        x2: x1 + wid * 0.6,
        y2: (y1 + y2) / 2
      },
      style: { stroke: "black" }
    })
    ret.children.push({
      type: "line",
      shape: {
        x1: x1 + wid * 0.7,
        y1: (y1 + y2) / 2,
        x2: x1 + wid * 0.9,
        y2: (y1 + y2) / 2
      },
      style: { stroke: "black" }
    })
  } else if (yxName == "fszny") {
    ret.children.push({
      type: "circle",
      shape: {
        cx: x1 + (wid * 1) / 10,
        cy: (y1 + y2) / 2,
        r: 1
      },
      style: { stroke: "black", fill: "black", lineWidth: 1 }
    })
    ret.children.push({
      type: "circle",
      shape: {
        cx: x1 + (wid * 2) / 10,
        cy: (y1 + y2) / 2,
        r: 1
      },
      style: { stroke: "black", fill: "black", lineWidth: 1 }
    })
    ret.children.push({
      type: "line",
      shape: {
        x1: x1 + wid * 0.4,
        y1: (y1 + y2) / 2,
        x2: x1 + wid * 0.6,
        y2: (y1 + y2) / 2
      },
      style: { stroke: "black", lineWidth: 1 }
    })
    ret.children.push({
      type: "line",
      shape: {
        x1: x1 + wid * 0.7,
        y1: (y1 + y2) / 2,
        x2: x1 + wid * 0.9,
        y2: (y1 + y2) / 2
      },
      style: { stroke: "black", lineWidth: 1 }
    })
  }
  return ret
}

export const yxOption = {
  tooltip: {
    formatter: function (params) {
      const [i, s, e] = params.value
      return params.marker + params.name + `<br />[${s}, ${e}]`
    }
  },
  grid: {
    top: "0",
    left: "0",
    right: "0",
    bottom: "0",
    containLabel: false
  },
  yAxis: [
    {
      inverse: true,
      scale: true,
      axisTick: {
        alignWithLabel: true
      }
    }
  ],
  xAxis: {
    data: [""]
  },
  series: [
    {
      type: "custom",
      renderItem: renderYanxing,
      encode: {
        y: [1, 2],
        x: 0
      },
      large: true,
      data: mockdataset1
    }
  ]
}
export const explainOption = {
  // tooltip: {},
  grid: {
    top: "0",
    left: "0",
    right: "0",
    bottom: "0",
    containLabel: false
  },
  yAxis: [
    {
      inverse: true,
      scale: true,
      axisTick: {
        alignWithLabel: true
      }
    }
  ],
  xAxis: {
    min: 0,
    max: 10,
    splitLine: {
      show: false,
      lineStyle: { color: "#8accc5" }
    },
    axisLine: {
      show: false // 隐藏 x 轴线
    },
    axisTick: {
      show: false // 隐藏 x 轴刻度
    },
    axisLabel: {
      show: false // 隐藏 x 轴刻度
    }
  },
  series: [
    {
      type: "custom",
      renderItem: renderExplain,
      encode: {
        y: [1, 2],
        x: 0
      },
      large: true,
      data: mockdataset2
    }
  ]
}
